'use strict';

const BaseController = require('./base');
const serviceName = 'college';

class CollegeController extends BaseController {
  constructor(ctx) {
    super(ctx, serviceName);
  }

  getListQuery(query) {
    const where = {};
    const { school_id, name } = query;

    if (school_id) {
      where.school_id = school_id;
    }
    
    if (name) {
      where.name = {
        [this.app.Sequelize.Op.like]: `%${name}%`
      };
    }

    return where;
  }
}

module.exports = CollegeController;
